console.log(".........publicHeader...........");
let publicHeader = new Vue({
    //element
    el: "#publicHeaderApp", //id为publicHeaderApp的元素会被vue托管
    data: {  //属性
        keyword:"",
        currentUserName:""
    },
    methods: {  //方法
        search(){
            console.log(this.keyword)
            console.log(index)
            if(this.keyword){
                //alert(this.keyword);
                //调用index对象的属性和方法    跨vue对象访问属性及方法
                index._data.keyword = this.keyword;
                index._data.currentPage=1;
                index.search();
            }
        }
        ,
        initCurrentUserName(){
            let vueObj = this;

            $.get("/user/currentUserName",function (data) {
                console.log(data)
                vueObj.currentUserName=data;
            })
        }
        ,
        logout(){
            $.get("/user/logout",function (data) {
                location.href="/"
            })
        }


    },
    //vue生命周期中调用
    created() {
        this.initCurrentUserName();
    }
});
